using System;

namespace YatFram.UnitTesting
{
    public class UnitTestContextWithBuilder<TUnitUnderTest> : IContext
    {
        protected IBuilder<TUnitUnderTest> _unitUnderTestBuilder;
        private object _returnValue;

        public void Dispose()
        {
            
        }

        public void Reset()
        {
            _unitUnderTestBuilder = null;
            _returnValue = null;
        }

        public void Dump()
        {
            Console.WriteLine("Unit Under Test [" + _unitUnderTestBuilder + "] Return value [" + _returnValue + "]" );
        }

        public void UnitUnderTestBuilder(IBuilder<TUnitUnderTest> builder)
        {
            _unitUnderTestBuilder = builder;
        }   

        public TUnitUnderTest UnitUnderTest()
        {
            return _unitUnderTestBuilder.Build();
        }

        public object ReturnValue
        {
            get { return _returnValue; }
            set { _returnValue = value; }
        }

        public void With<T>(IFake<T> fake)
        {
            _unitUnderTestBuilder.With(fake);
        }
    }
}